/*
 * Example: Basice in heritance 
 *
 * Date: Sep.08.2014
 *
 * Reference: http://www.tutorialspoint.com/cplusplus/cpp_inheritance.htm *
 *
 * Note: 
 *   1. Make the member variable as "protected"
 *   2. Use the typeid to obtain the infoabout the class type.
 */

#include <iostream>
#include <typeinfo>

using namespace std;

class Shape
{
  public:
    float getWidth()
    {
      return width;
    }

    float getHeight()
    {
      return height;
    }

    void setWidth(float w)
    {
      width = w;
    }

    void setHeight(float h)
    {
      height = h;
    }

    string toString()
    {
      return "This is a shape object.";
    }

  protected:
    float width;
    float height;
};

class Rectangular: public Shape
{
  public:
    float getArea()
    {
      return width * height;
    }

    string toString()
    {
      return "This is a rectangular object.";
    }
};

int main()
{
  Rectangular rectangular_1;
  rectangular_1.setWidth(5);
  rectangular_1.setHeight(10);
  cout << "rectangular_1.getArea() = " << rectangular_1.getArea() << endl;
  cout << "rectangular_1.toString() = " << rectangular_1.toString() << endl;
  cout << "rectangular_1.shape::toString() = " << rectangular_1.Shape::toString() << endl;
  cout << "typeid(rectangular_1).name() = " << typeid(rectangular_1).name() << endl;
}
